<?php
include_once('./common.inc.php');
$smarty = new Tpl();
//产品信息
$id = intval(get_param('id'));
if( empty($id) ) msg('非法id');
$tpl = __ROOT__.'product'.DIRECTORY_SEPARATOR.$id.'.html';
if( !$smarty->isCached("product.html") /*|| !file_exists($tpl)*/ ){	
	$proModel = new Model('product');

	//导航
	$proModel = new Model('product');
	$product = $proModel->field(array('id','name'))->order('`order`,id DESC')->get();
	$smarty->assign("product", $product);

	$proModel->free_result();
	$proinfo = $proModel->where("id=$id")->get_one();
	$smarty->assign("proinfo", $proinfo);
	$smarty->assign("keywords", $proinfo['keywords']);
	$smarty->assign("titles", $proinfo['titles']);
	$smarty->assign("descriptions", $proinfo['descriptions']);

	//产品图片
	$proPicModel = new Model('product_picture');
	$proPics = $proPicModel->where("product_id=$id")->get();
	$smarty->assign('proPics', $proPics);

	//评论
	$comModel = new Model("comment");
	$comms = $comModel->where("p_id=$id")->order('id DESC')->get();
	$smarty->assign("comms", $comms);
	/*$html = $smarty->fetch("product.html");
	if( !empty($html) ){
		$rs = @file_put_contents(__ROOT__."product/$id.html", $html);
	}*/
}
//header("location:".__URL__."product/$id.html");
$smarty->display('product.html');
